package com.entity;

import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonManagedReference;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import javax.persistence.*;
import java.util.List;

@Entity
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class Question extends  BaseEntity{
    @Transient
    final Integer q_singleC=0;
    @Transient
    final Integer q_judgmental=1;
    @Transient
    final Integer q_multipleC=2;

    private Integer type;

    private String content;

    private String analysis;

    private Integer ordinal;

    @OneToMany (cascade = CascadeType.PERSIST,mappedBy = "question")
    private List<Option> options;

    @ManyToOne
    private Chapter chapter;

    @OneToMany(mappedBy = "question")
    private List<Result> results;

    @JsonBackReference
    public Chapter getChapter() {
        return chapter;
    }

    public void setChapter(Chapter chapter) {
        this.chapter = chapter;
    }

    @JsonManagedReference
    public List<Option> getOptions() {
        return options;
    }

    public void setOptions(List<Option> options) {
        this.options = options;
    }

    @JsonManagedReference
    public List<Result> getResults() {
        return results;
    }

    public void setResults(List<Result> results) {
        this.results = results;
    }
}
